package com.ctshk.app.scenic.controller;

import com.ctshk.common.dto.Result;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.scenic.dto.app.ScenicProductEsDetailDTO;
import com.ctshk.rpc.scenic.dto.app.ScenicProductEsInfoDTO;
import com.ctshk.rpc.scenic.dto.app.ScenicProductEsListDTO;
import com.ctshk.rpc.scenic.dto.app.ScenicProductTypeListDTO;
import com.ctshk.rpc.scenic.dto.app.inner.ScenicTicketListDTO;
import com.ctshk.rpc.scenic.req.app.ScenicProductEsListReq;
import com.ctshk.rpc.scenic.req.app.ScenicProductEsReq;
import com.ctshk.rpc.scenic.service.app.IScenicProductTypeService;
import com.ctshk.rpc.scenic.service.app.IScenicTicketEsSearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *     景区门票ES 控制器
 * </p>
 * @author 黄先
 */
@RestController
@RequestMapping("/es")
@SuppressWarnings("all")
@Api(value = "景区门票ES", tags = "景区门票ES")
public class ScenicTicketEsController extends BaseController {

    @DubboReference
    IScenicTicketEsSearchService iScenicTicketEsSearchService;

    @DubboReference
    IScenicProductTypeService iScenicProductTypeService;

    @GetMapping("/selectScenicProductTypeList")
    @ApiOperation(value = "查询门票分类列表", notes = "查询门票分类列表")
    public Result<List<ScenicProductTypeListDTO>> selectScenicProductTypeList(){
        return Result.success(iScenicProductTypeService.selectScenicProductTypeList());
    }

    @PostMapping("/selectScenicEsTicketList")
    @ApiOperation(value = "查询门票列表ES", notes = "查询门票列表")
    public Result<PageResponse<ScenicTicketListDTO>> selectScenicEsTicketList(@RequestBody ScenicProductEsListReq scenicProductEsListReq, @RequestParam(required = false, defaultValue = "1") Integer pageNum, @RequestParam(required = false, defaultValue = "10") Integer pageSize){
        return iScenicTicketEsSearchService.selectScenicEsTicketList(scenicProductEsListReq, pageNum, pageSize);
    }

    @GetMapping("/selectScenicEsInfo/{channelId}/{productId}/{scenicId}/{attrId}")
    @ApiOperation(value = "查询门票列表具体规格信息", notes = "查询门票列表具体规格信息")
    public Result<ScenicProductEsInfoDTO> selectScenicEsInfo(@PathVariable("channelId") Long channelId, @PathVariable("productId") Long productId, @PathVariable("scenicId") Long scenicId, @PathVariable("attrId") Long attrId){
        return iScenicTicketEsSearchService.selectScenicEsInfo(channelId, productId, scenicId, attrId);
    }

    @GetMapping("/selectScenicDetailEs/{channelId}/{productId}")
    @ApiOperation(value = "查询门票详情ES", notes = "查询门票详情")
    public Result<ScenicProductEsDetailDTO> selectScenicDetailEs(@PathVariable("channelId") Long channelId, @PathVariable("productId") Long productId){
        return Result.success(iScenicTicketEsSearchService.selectScenicDetailEs(channelId, productId,getCurrentUserAllowNotLogInUserId()));
    }

    @GetMapping("/initIndex")
    @ApiOperation(value = "重置scenic_ticket_online索引 临时代替task，上线后使用task", notes = "重置scenic_ticket_online索引 临时替代task，上线后使用task")
    public Result<String> initIndex(){
        return Result.success(iScenicTicketEsSearchService.initIndex());
    }
}
